import React, { Component } from 'react'
import { Input, Select } from 'antd'
import { getExamType } from '../../../api/exam'
// 富文本编辑器
import ReactWEditor from 'wangeditor-for-react'
const { Option } = Select

export default class AddManagement extends Component {
    state = {
        questionInfo: {
            // 题干
            questions_stem: "题干",
            // 试题的标题
            title: "题目主题",
            // 试题类型id
            questions_type_id: "",
            // 课程id
            subject_id: "",
            // 考试类型id
            exam_id: "",
            // 题目答案
            questions_answer: ""
        },
        // 考试类型
        questions: []
    }
    render() {
        const { questions } = this.state
        return (
            <div>
                <h4>题目信息</h4>
                <ul>
                    <li>
                        <h5>题干</h5>
                        <Input placeholder="Basic usage" />
                    </li>
                    <li>
                        <h5>题目主题</h5>
                        <ReactWEditor
                            // value={value}
                            onChange={(html) => {
                                console.log('html:', html)
                            }}
                        />
                    </li>
                    <li>
                        <h5>请选择考试类型：</h5>
                        <Select defaultValue="周考1" style={{ width: 120 }} onChange={this.handleChange}>
                            {
                                questions.map(item => {
                                    return <Option key={item.exam_id} value={item.exam_id}>
                                        {item.exam_name}
                                    </Option>
                                })
                            }
                        </Select>
                    </li>
                    <li>
                        <h5>请选择课程类型：</h5>
                        <Select defaultValue="lucy" style={{ width: 120 }} onChange={this.handleChange}>
                            <Option value="jack">Jack</Option>
                            <Option value="lucy">Lucy</Option>
                            <Option value="Yiminghe">yiminghe</Option>
                        </Select>
                    </li>
                    <li>
                        <h5>请选择题目类型：</h5>
                        <Select defaultValue="lucy" style={{ width: 120 }} onChange={this.handleChange}>
                            <Option value="jack">Jack</Option>
                            <Option value="lucy">Lucy</Option>
                            <Option value="Yiminghe">yiminghe</Option>
                        </Select>
                    </li>
                    <li>
                        <h5>答案信息</h5>
                        <Input placeholder="Basic usage" />
                    </li>
                </ul>
            </div>
        )
    }
    handleChange = (value) => {
        console.log(`selected ${value}`)
    }
    componentDidMount() {
        getExamType().then(res => {
            this.setState({
                questions: res.data.data
            })
        })
    }
}
